package com.itheima.utils;

import com.itheima.pojo.Result;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionHandler {

    @org.springframework.web.bind.annotation.ExceptionHandler(value = Exception.class)
    public Result error(Exception e) {
        e.printStackTrace();
        return Result.error("出错了请找工作人员");
    }

    @org.springframework.web.bind.annotation.ExceptionHandler(value = RuntimeException.class)
    public Result error2(RuntimeException r) {
        r.printStackTrace();
        return Result.error("对不起，当前部门下有员工，不能直接删除");
    }

    @org.springframework.web.bind.annotation.ExceptionHandler(value = BusinessException.class)
    public Result error3(BusinessException b) {
        b.printStackTrace();
        return Result.error("对不起，当前班级下有员工，不能直接删除");
    }

    @org.springframework.web.bind.annotation.ExceptionHandler(value = OneException.class)
    public Result error3(OneException o) {
        o.printStackTrace();
        return Result.error(o.getMessage());
    }

}
